package com.cn.common.pojo;

public class ResultModel {

    private String msg;
    private Integer code;
    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    private Integer count;
    private Object data;
    private static ResultModel resultModel;
    public static ResultModel getResultModel(String msg, Integer code, Integer count, Object data){
//        if (resultModel==null){
        resultModel=new ResultModel();
//    }
        resultModel.setData(data);
        resultModel.setCode(code);
        resultModel.setCount(count);
        resultModel.setMsg(msg);
        return resultModel;

    }
    public static ResultModel Data(Object data){
        if (resultModel==null){
            resultModel=new ResultModel();
        }
        resultModel.setData(data);
        return resultModel;
    }
    private ResultModel(){

    }

    private ResultModel(ResultEnum resultEnum){
        this.code=resultEnum.SUCCESS.getCode();
        this.msg=resultEnum.SUCCESS.getMessage();

    }
//    public static ResultModel getResultModelByMsg(String msg) {
////        if (resultModel == null) {
//            resultModel = new ResultModel();
////        }
//        resultModel.setMsg(msg);
//        return resultModel;
//    }
    public static ResultModel getResultModelByCount(int count) {
//        if (resultModel == null) {
            resultModel = new ResultModel();
//        }
        resultModel.setCount(count);
        return resultModel;
    }

    public static ResultModel getResultModelByAll(Object data, int count) {
//        if (resultModel == null) {
        resultModel = new ResultModel();
//       }
        resultModel.setCount(count);
        resultModel.setData(data);
        return resultModel;
    }
    public static ResultModel success(Object data, int count) {
//        if (resultModel == null) {
        resultModel = new ResultModel();
//       }
        resultModel.code= ResultEnum.SUCCESS.getCode();
        resultModel.msg= ResultEnum.SUCCESS.getMessage();
        resultModel.setCount(count);
        resultModel.setData(data);
        return resultModel;
    }

    public static ResultModel error() {
//        if (resultModel == null) {
        resultModel = new ResultModel();
//       }
        resultModel.code= ResultEnum.ERROR.getCode();
        resultModel.msg= ResultEnum.ERROR.getMessage();
        return resultModel;
    }
    public static ResultModel success(Object data) {
//        if (resultModel == null) {
        resultModel = new ResultModel();
        resultModel.code= ResultEnum.SUCCESS.getCode();
        resultModel.msg= ResultEnum.SUCCESS.getMessage();
        resultModel.setData(data);
        return resultModel;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
